# Copyright 2024 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:psi.bzl", "psi_cc_binary", "psi_cc_library", "psi_cc_test")

package(default_visibility = ["//visibility:public"])

psi_cc_library(
    name = "polynomial",
    srcs = [
        "polynomial.cc",
    ],
    hdrs = [
        "polynomial.h",
    ],
    deps = [
        "@com_github_openssl_openssl//:openssl",
        "@com_google_absl//absl/strings",
        "@yacl//yacl/base:exception",
    ],
)

psi_cc_test(
    name = "polynomial_test",
    srcs = ["polynomial_test.cc"],
    deps = [
        ":polynomial",
        "@yacl//yacl/crypto/tools:prg",
    ],
)

psi_cc_library(
    name = "mini_psi",
    srcs = ["mini_psi.cc"],
    hdrs = ["mini_psi.h"],
    defines = ["CURVE25519_DONNA"],
    deps = [
        ":polynomial",
        "//psi/utils:batch_provider",
        "//psi/utils:communication",
        "//psi/utils:cuckoo_index",
        "//psi/utils:serialize",
        "//psi/utils:test_utils",
        "@com_github_floodyberry_curve25519_donna//:curve25519_donna",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest",
        "@yacl//yacl/crypto/hash:hash_utils",
        "@yacl//yacl/crypto/tools:prg",
        "@yacl//yacl/link",
        "@yacl//yacl/utils:parallel",
    ],
)

psi_cc_test(
    name = "mini_psi_test",
    srcs = ["mini_psi_test.cc"],
    flaky = True,
    deps = [
        ":mini_psi",
    ],
)

psi_cc_binary(
    name = "mini_psi_demo",
    srcs = ["mini_psi_demo.cc"],
    deps = [
        ":mini_psi",
        "//psi/ecdh:ecdh_psi",
    ],
)
